/**
 * @author 黄波
 * 创建日期：2011Oct 14, 2011
 * TODO// N/A
 */
package com.platform.njcc.action;

import java.util.ArrayList;
import java.util.List;

import com.platform.bean.PageBean;
import com.platform.common.bo.CommonBo;
import com.platform.course.bean.CourseBean;
import com.platform.course.bo.CourseBo;
import com.platform.pojo.CourseInfo;
import com.platform.pojo.SchoolProperty;
import com.platform.user.bo.UserBo;

/**
 * 加载所有课程信息列表
 */
public class LoadAllCourseAction extends NJCCSuport {

	private PageBean pageBean;
	
	private List<CourseBean> courselist = new ArrayList<CourseBean>();	//课程互动列表
	
	@Override
	public String execute() throws Exception {
		Object[] objs = CourseBo.getInstance().getInfos(pageBean);

		pageBean = (PageBean) objs[0];
		List<CourseInfo> infos = (List) objs[1];

		//查询课程互动信息列表
		//公共属性
		CommonBo commonBo = CommonBo.getInstance();
		if(infos != null) {
			for(CourseInfo item : infos) {
				CourseBean bean = new CourseBean();
				//课程实体
				bean.setItem(item);
				//任课老师
				bean.setTeacher(UserBo.getInstance().getUser(item.getUserId().toString()).getRealName());
				//班级名称
				SchoolProperty sp = commonBo.getSchoolProperty(item.getClassId().toString());
				if(sp != null) {
					bean.setClassName(sp.getName());
					bean.setClassNum(sp.getClassNum().toString());
				}
				courselist.add(bean);
			}
		}
		return SUCCESS;
	}
	public PageBean getPageBean() {
		return pageBean;
	}
	public void setPageBean(PageBean pageBean) {
		this.pageBean = pageBean;
	}
	public List<CourseBean> getCourselist() {
		return courselist;
	}
	public void setCourselist(List<CourseBean> courselist) {
		this.courselist = courselist;
	}
}
